Change in openvpn[master]: OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
A message that is not in the archive (sent off-list or not yet received): gerrit.1774974242000.I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5@...2715...
plaisthos has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email )
Change subject: OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
......................................................................
OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
The X509_cmp_time function is deprecated in OpenSSL 4.0. So we avoid it and use the new API.
---
M src/openvpn/ssl_openssl.c
1 file changed, 47 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/95/1595/1
src/openvpn/ssl_openssl.c +47 -0
@@ -634,6 +634,7 @@#endif /* if OPENSSL_VERSION_NUMBER < 0x30000000L */ } +#if OPENSSL_VERSION_NUMBER <0x40000000L void tls_ctx_check_cert_time (const struct tls_root_ctx *ctx) {
@@ -669,6 +670,52 @@ msg(M_WARN, "WARNING: Your certificate has expired!"); } } +#else +void +tls_ctx_check_cert_time (const struct tls_root_ctx *ctx) +{ +const X509 *cert; +ASSERT (ctx); + + cert =SSL_CTX_get0_certificate (ctx->ctx); + +if (cert ==NULL ) + { +return ;/* Nothing to check if there is no certificate */ + } + +X509_VERIFY_PARAM *vpm =X509_VERIFY_PARAM_new (); + +if (vpm ==NULL ) + { +msg (D_TLS_DEBUG_MED ,"Failed to initialise certificate verification parameters." ); + } + +X509_VERIFY_PARAM_set_flags (vpm,X509_V_FLAG_USE_CHECK_TIME ); +X509_VERIFY_PARAM_set_time (vpm, now); + +int error =0 ; +int ret =X509_check_certificate_times (vpm, cert, &error); + +if (error ==X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD ) + { +msg (D_TLS_DEBUG_MED ,"Failed to read certificate notBefore field." ); + } +if (error ==X509_V_ERR_CERT_NOT_YET_VALID ) + { +msg (M_WARN ,"WARNING: Your certificate is not yet valid!" ); + } +if (ret ==X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD ) + { +msg (D_TLS_DEBUG_MED ,"Failed to read certificate notAfter field." ); + } +if (error ==X509_V_ERR_CERT_HAS_EXPIRED ) + { +msg (M_WARN ,"WARNING: Your certificate has expired!" ); + } +X509_VERIFY_PARAM_free (vpm); +} +#endif void tls_ctx_load_dh_params (struct tls_root_ctx *ctx,const char *dh_file,bool dh_file_inline)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5
Gerrit-Change-Number: 1595
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Attention is currently required from: plaisthos.
flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email )
Change subject: OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
......................................................................
Patch Set 2: Code-Review-1
(2 comments)
File src/openvpn/ssl_openssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1595/comment/ce3d6801_f2791ace?usp=email :
PS2, Line 691: msg(D_TLS_DEBUG_MED, "Failed to initialise certificate verification parameters.");
Shouldn't we return from the function here?
http://gerrit.openvpn.net/c/openvpn/+/1595/comment/ed877e20_2571c8e7?usp=email :
PS2, Line 708: if (ret == X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD)
error, not ret
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5
Gerrit-Change-Number: 1595
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Wed, 01 Apr 2026 10:34:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Attention is currently required from: flichtenheld.
plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email )
Change subject: OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
......................................................................
Patch Set 2:
(2 comments)
File src/openvpn/ssl_openssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1595/comment/9936038d_d6f94305?usp=email :
PS2, Line 691: msg(D_TLS_DEBUG_MED, "Failed to initialise certificate verification parameters.");
Quoted 1 line
Shouldn't we return from the function here?
yeah. Good catch
http://gerrit.openvpn.net/c/openvpn/+/1595/comment/2d685abe_e195c5f2?usp=email :
PS2, Line 708: if (ret == X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD)
Quoted 1 line
error, not ret
Acknowledged
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5
Gerrit-Change-Number: 1595
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 01 Apr 2026 11:34:25 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Attention is currently required from: flichtenheld.
Hello flichtenheld,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email
to look at the new patch set (#3).
The following approvals got outdated and were removed:
Code-Review-1 by flichtenheld
Change subject: OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
......................................................................
OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
The X509_cmp_time function is deprecated in OpenSSL 4.0. So we avoid it and use the new API.
---
M src/openvpn/ssl_openssl.c
1 file changed, 53 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/95/1595/3
src/openvpn/ssl_openssl.c +53 -0
@@ -615,6 +615,7 @@#endif /* if OPENSSL_VERSION_NUMBER < 0x30000000L */ } +#if OPENSSL_VERSION_NUMBER <0x40000000L void tls_ctx_check_cert_time (const struct tls_root_ctx *ctx) {
@@ -650,6 +651,58 @@ msg(M_WARN, "WARNING: Your certificate has expired!"); } } +#else +void +tls_ctx_check_cert_time (const struct tls_root_ctx *ctx) +{ +const X509 *cert; +ASSERT (ctx); + + cert =SSL_CTX_get0_certificate (ctx->ctx); + +if (cert ==NULL ) + { +return ;/* Nothing to check if there is no certificate */ + } + +X509_VERIFY_PARAM *vpm =X509_VERIFY_PARAM_new (); + +if (vpm ==NULL ) + { +msg (D_TLS_DEBUG_MED ,"Failed to initialise certificate verification parameters." ); +return ; + } + +X509_VERIFY_PARAM_set_flags (vpm,X509_V_FLAG_USE_CHECK_TIME ); +X509_VERIFY_PARAM_set_time (vpm, now); + +int error =0 ; +int ret =X509_check_certificate_times (vpm, cert, &error); +X509_VERIFY_PARAM_free (vpm); + +if (ret ==1 ) + { +return ; + } + +if (error ==X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD ) + { +msg (D_TLS_DEBUG_MED ,"Failed to read certificate notBefore field." ); + } +if (error ==X509_V_ERR_CERT_NOT_YET_VALID ) + { +msg (M_WARN ,"WARNING: Your certificate is not yet valid!" ); + } +if (error ==X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD ) + { +msg (D_TLS_DEBUG_MED ,"Failed to read certificate notAfter field." ); + } +if (error ==X509_V_ERR_CERT_HAS_EXPIRED ) + { +msg (M_WARN ,"WARNING: Your certificate has expired!" ); + } +} +#endif void tls_ctx_load_dh_params (struct tls_root_ctx *ctx,const char *dh_file,bool dh_file_inline)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5
Gerrit-Change-Number: 1595
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Attention is currently required from: plaisthos.
flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email )
Change subject: OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
......................................................................
Patch Set 3:
(1 comment)
File src/openvpn/ssl_openssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1595/comment/7faf7350_74c0cf48?usp=email :
PS3, Line 688: if (error == X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD)
Not sure whether that is bikeshedding, but should we maybe use a case statement here? Looks more appropriate for checking the same variable against 4 values.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5
Gerrit-Change-Number: 1595
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Sat, 04 Apr 2026 16:51:32 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Hello flichtenheld,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email
to look at the new patch set (#5).
Change subject: OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
......................................................................
OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
The X509_cmp_time function is deprecated in OpenSSL 4.0. So we avoid it and use the new API.
---
M src/openvpn/ssl_openssl.c
1 file changed, 55 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/95/1595/5
src/openvpn/ssl_openssl.c +55 -0
@@ -634,6 +634,7 @@#endif /* if OPENSSL_VERSION_NUMBER < 0x30000000L */ } +#if OPENSSL_VERSION_NUMBER <0x40000000L void tls_ctx_check_cert_time (const struct tls_root_ctx *ctx) {
@@ -669,6 +670,60 @@ msg(M_WARN, "WARNING: Your certificate has expired!"); } } +#else +void +tls_ctx_check_cert_time (const struct tls_root_ctx *ctx) +{ +const X509 *cert; +ASSERT (ctx); + + cert =SSL_CTX_get0_certificate (ctx->ctx); + +if (cert ==NULL ) + { +return ;/* Nothing to check if there is no certificate */ + } + +X509_VERIFY_PARAM *vpm =X509_VERIFY_PARAM_new (); + +if (vpm ==NULL ) + { +msg (D_TLS_DEBUG_MED ,"Failed to initialise certificate verification parameters." ); +return ; + } + +X509_VERIFY_PARAM_set_flags (vpm,X509_V_FLAG_USE_CHECK_TIME ); +X509_VERIFY_PARAM_set_time (vpm, now); + +int error =0 ; +int ret =X509_check_certificate_times (vpm, cert, &error); +X509_VERIFY_PARAM_free (vpm); + +if (ret ==1 ) + { +return ; + } + +switch (error) + { +case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD : +msg (D_TLS_DEBUG_MED ,"Failed to read certificate notBefore field." ); +break ; + +case X509_V_ERR_CERT_NOT_YET_VALID : +msg (M_WARN ,"WARNING: Your certificate is not yet valid!" ); +break ; + +case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD : +msg (D_TLS_DEBUG_MED ,"Failed to read certificate notAfter field." ); +break ; + +case X509_V_ERR_CERT_HAS_EXPIRED : +msg (M_WARN ,"WARNING: Your certificate has expired!" ); +break ; + } +} +#endif void tls_ctx_load_dh_params (struct tls_root_ctx *ctx,const char *dh_file,bool dh_file_inline)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5
Gerrit-Change-Number: 1595
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Attention is currently required from: plaisthos.
mandree has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email )
Change subject: OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
......................................................................
Patch Set 5:
(2 comments)
Patchset:
PS5:
So we're using a switch to decode a subset of errors - certainly the most likely ones, but should there be a fallback path for all other errors to report them?
File src/openvpn/ssl_openssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1595/comment/ec8212fc_9969e4dd?usp=email :
PS5, Line 724: }
The followup question to Frank's is whether there should be a default branch decoding other error values in a generic way and report them.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5
Gerrit-Change-Number: 1595
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: mandree <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Fri, 17 Apr 2026 10:58:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Attention is currently required from: plaisthos.
cron2 has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email )
Change subject: OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
......................................................................
Patch Set 5: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5
Gerrit-Change-Number: 1595
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: mandree <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Fri, 17 Apr 2026 16:44:37 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: flichtenheld, mandree, plaisthos.
cron2 has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email )
Change subject: OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
......................................................................
Patch Set 5:
(3 comments)
Patchset:
PS5:
After some quick discussion we didn't feel like doing another round - the API documentation says "these 4 error codes are possible" and it's hard to imagine anything else (a generic "EWEIRDFAILURE" can always be signalled as one of the two "cannot read <time> from cert" errors). So we progress here, for now.
File src/openvpn/ssl_openssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1595/comment/4abd9506_936c6580?usp=email :
PS3, Line 688: if (error == X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD)
Quoted 1 line
Not sure whether that is bikeshedding, but should we maybe use a case statement here? Looks more app […]
Done
File src/openvpn/ssl_openssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1595/comment/60f7cadb_7d8a7424?usp=email :
PS5, Line 724: }
Quoted 1 line
The followup question to Frank's is whether there should be a default branch decoding other error va […]
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5
Gerrit-Change-Number: 1595
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: mandree <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mandree <[email protected]...>
Gerrit-Comment-Date: Fri, 17 Apr 2026 16:46:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: mandree <[email protected]...>
PATCH v5 1/1 OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
In reply to a message not in the archiveFrom: Arne Schwabe <[email protected]...>
The X509_cmp_time function is deprecated in OpenSSL 4.0. So we avoid it and use the new API.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1595
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1595
This mail reflects revision 5 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/ssl_openssl.c +55 -0
@@ -634,6 +634,7 @@#endif /* if OPENSSL_VERSION_NUMBER < 0x30000000L */ } +#if OPENSSL_VERSION_NUMBER <0x40000000L void tls_ctx_check_cert_time (const struct tls_root_ctx *ctx) {
@@ -669,6 +670,60 @@ msg(M_WARN, "WARNING: Your certificate has expired!"); } } +#else +void +tls_ctx_check_cert_time (const struct tls_root_ctx *ctx) +{ +const X509 *cert; +ASSERT (ctx); + + cert =SSL_CTX_get0_certificate (ctx->ctx); + +if (cert ==NULL ) + { +return ;/* Nothing to check if there is no certificate */ + } + +X509_VERIFY_PARAM *vpm =X509_VERIFY_PARAM_new (); + +if (vpm ==NULL ) + { +msg (D_TLS_DEBUG_MED ,"Failed to initialise certificate verification parameters." ); +return ; + } + +X509_VERIFY_PARAM_set_flags (vpm,X509_V_FLAG_USE_CHECK_TIME ); +X509_VERIFY_PARAM_set_time (vpm, now); + +int error =0 ; +int ret =X509_check_certificate_times (vpm, cert, &error); +X509_VERIFY_PARAM_free (vpm); + +if (ret ==1 ) + { +return ; + } + +switch (error) + { +case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD : +msg (D_TLS_DEBUG_MED ,"Failed to read certificate notBefore field." ); +break ; + +case X509_V_ERR_CERT_NOT_YET_VALID : +msg (M_WARN ,"WARNING: Your certificate is not yet valid!" ); +break ; + +case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD : +msg (D_TLS_DEBUG_MED ,"Failed to read certificate notAfter field." ); +break ; + +case X509_V_ERR_CERT_HAS_EXPIRED : +msg (M_WARN ,"WARNING: Your certificate has expired!" ); +break ; + } +} +#endif void tls_ctx_load_dh_params (struct tls_root_ctx *ctx,const char *dh_file,bool dh_file_inline)
[Openvpn-devel] [PATCH applied] Re: OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
So, for "non openssl 4.0" builds, this patch has no effect. With 4.0, we get compile warnings without this patch, and it compiles fine with it - and for a profile I had around with an expired cert, it shows the expected message. All the error codes that are documented as possible return values are handled, though I cannot test this (I guess you need to produce a corrupt cert for two of them).
As for "add a default clause for yet-unknown error messages", we decided against (because there are not really any other ways this could fail, and even if, it's just a helper function to tell users that their certificate lifetime is in conflict with local date, which might or might not lead to problems connecting).
Your patch has been applied to the master and release/2.7 branch.
commit 353ec724f9bc1dceb36760eceee0a128e140044c (master) commit 8747fcf641214d4f05de53f9db825f396049e3d3 (release/2.7)
Author: Arne Schwabe Date: Fri Apr 17 18:46:38 2026 +0200
OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1595
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36651.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#6) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
......................................................................
OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
The X509_cmp_time function is deprecated in OpenSSL 4.0. So we avoid it and use the new API.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1595
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36651.html
---
M src/openvpn/ssl_openssl.c
1 file changed, 55 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/95/1595/6
src/openvpn/ssl_openssl.c +55 -0
@@ -634,6 +634,7 @@#endif /* if OPENSSL_VERSION_NUMBER < 0x30000000L */ } +#if OPENSSL_VERSION_NUMBER <0x40000000L void tls_ctx_check_cert_time (const struct tls_root_ctx *ctx) {
@@ -669,6 +670,60 @@ msg(M_WARN, "WARNING: Your certificate has expired!"); } } +#else +void +tls_ctx_check_cert_time (const struct tls_root_ctx *ctx) +{ +const X509 *cert; +ASSERT (ctx); + + cert =SSL_CTX_get0_certificate (ctx->ctx); + +if (cert ==NULL ) + { +return ;/* Nothing to check if there is no certificate */ + } + +X509_VERIFY_PARAM *vpm =X509_VERIFY_PARAM_new (); + +if (vpm ==NULL ) + { +msg (D_TLS_DEBUG_MED ,"Failed to initialise certificate verification parameters." ); +return ; + } + +X509_VERIFY_PARAM_set_flags (vpm,X509_V_FLAG_USE_CHECK_TIME ); +X509_VERIFY_PARAM_set_time (vpm, now); + +int error =0 ; +int ret =X509_check_certificate_times (vpm, cert, &error); +X509_VERIFY_PARAM_free (vpm); + +if (ret ==1 ) + { +return ; + } + +switch (error) + { +case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD : +msg (D_TLS_DEBUG_MED ,"Failed to read certificate notBefore field." ); +break ; + +case X509_V_ERR_CERT_NOT_YET_VALID : +msg (M_WARN ,"WARNING: Your certificate is not yet valid!" ); +break ; + +case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD : +msg (D_TLS_DEBUG_MED ,"Failed to read certificate notAfter field." ); +break ; + +case X509_V_ERR_CERT_HAS_EXPIRED : +msg (M_WARN ,"WARNING: Your certificate has expired!" ); +break ; + } +} +#endif void tls_ctx_load_dh_params (struct tls_root_ctx *ctx,const char *dh_file,bool dh_file_inline)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5
Gerrit-Change-Number: 1595
Gerrit-PatchSet: 6
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: mandree <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email )
Change subject: OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
......................................................................
OpenSSL 4.0: Use X509_check_certificate_times instead of X509_cmp_time
The X509_cmp_time function is deprecated in OpenSSL 4.0. So we avoid it and use the new API.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1595
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36651.html
---
M src/openvpn/ssl_openssl.c
1 file changed, 55 insertions(+), 0 deletions(-)
src/openvpn/ssl_openssl.c +55 -0
@@ -634,6 +634,7 @@#endif /* if OPENSSL_VERSION_NUMBER < 0x30000000L */ } +#if OPENSSL_VERSION_NUMBER <0x40000000L void tls_ctx_check_cert_time (const struct tls_root_ctx *ctx) {
@@ -669,6 +670,60 @@ msg(M_WARN, "WARNING: Your certificate has expired!"); } } +#else +void +tls_ctx_check_cert_time (const struct tls_root_ctx *ctx) +{ +const X509 *cert; +ASSERT (ctx); + + cert =SSL_CTX_get0_certificate (ctx->ctx); + +if (cert ==NULL ) + { +return ;/* Nothing to check if there is no certificate */ + } + +X509_VERIFY_PARAM *vpm =X509_VERIFY_PARAM_new (); + +if (vpm ==NULL ) + { +msg (D_TLS_DEBUG_MED ,"Failed to initialise certificate verification parameters." ); +return ; + } + +X509_VERIFY_PARAM_set_flags (vpm,X509_V_FLAG_USE_CHECK_TIME ); +X509_VERIFY_PARAM_set_time (vpm, now); + +int error =0 ; +int ret =X509_check_certificate_times (vpm, cert, &error); +X509_VERIFY_PARAM_free (vpm); + +if (ret ==1 ) + { +return ; + } + +switch (error) + { +case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD : +msg (D_TLS_DEBUG_MED ,"Failed to read certificate notBefore field." ); +break ; + +case X509_V_ERR_CERT_NOT_YET_VALID : +msg (M_WARN ,"WARNING: Your certificate is not yet valid!" ); +break ; + +case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD : +msg (D_TLS_DEBUG_MED ,"Failed to read certificate notAfter field." ); +break ; + +case X509_V_ERR_CERT_HAS_EXPIRED : +msg (M_WARN ,"WARNING: Your certificate has expired!" ); +break ; + } +} +#endif void tls_ctx_load_dh_params (struct tls_root_ctx *ctx,const char *dh_file,bool dh_file_inline)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1595?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6c2eda0e5bbb3a70b404f821e25ded81f0f5ddd5
Gerrit-Change-Number: 1595
Gerrit-PatchSet: 6
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: mandree <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>